package com.wei;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.IntStream;

import com.wei.io.MapConfigLoader;
import com.wei.model.MapConfig;

public class Startup {

	public static void main(String[] args) {
		
		MapConfig mapConfig = MapConfigLoader.getInstance().getMapConfig();
		BaiduSourceProvider tmsSourceProvider = new BaiduSourceProvider(mapConfig);
		
//		List<TileCoord> list = tmsSourceProvider.enumerateTileRange(null);
//		list.forEach(tc -> {
//			String url = tmsSourceProvider.getRequestUrl(tc);
//			String url2 = tmsSourceProvider.getRequestUrl(tmsSourceProvider.getNextTileCoord());
//			System.out.println("flag:"+url.equals(url2)+",url:"+url+",url2:"+url2);
//		});
//
		ExecutorService pool = Executors.newFixedThreadPool(mapConfig.getTaskThreadCount());
		IntStream.range(0, mapConfig.getTaskThreadCount()).forEach(i -> {
			pool.execute(new TaskThread(tmsSourceProvider, "thead-"+i, mapConfig));
		});
	}

}
